const express=require("express")
const router=express.Router();
const pool=require("../pool");

router.get("/",(req,res)=>{
  //创建一个接收数据的对象
  var carImgsData={
    carSurfaceImg:{},
    carDetailImg:{}
  };
  var id=req.query.did;
  new Promise((resolve,reject)=>{
    var sql=`select
             pid,src
             FROM car_details_surfaceImgs
             WHERE did=?`;
    pool.query(sql,[id],(err,result)=>{
      if(err) console.log(err);
     // res.send({code:1,data:result});
     carImgsData.carSurfaceImg=result;
      resolve(true);
    })
  }).then(value=>{
    return new Promise((resolve,reject)=>{
      var sql=`select
               pid,src
               FROM car_details_detailImgs
               WHERE did=?`;
      pool.query(sql,[id],(err,result)=>{
        if(err) console.log(err);
        carImgsData.carDetailImg=result;
        res.send({code:1,data:carImgsData});
        res.end();
      })
    })
  })
})
module.exports=router;